import { AttributeViewInfo, OAVComponent } from '@feng3d/objectview';
import { watcher } from '@feng3d/watcher';
import GUI, { BooleanController } from 'lil-gui';
import { OAVBase } from './OAVBase';

@OAVComponent('OAVBoolean')
export class OAVBoolean extends OAVBase
{
    private _controller: BooleanController;

    initview(gui: GUI)
    {
        this._controller = gui.add(this._space, this._attributeName) as BooleanController;

        watcher.watch(this._space, this._attributeName, this.updateView, this);
    }

    dispose()
    {
        watcher.unwatch(this._space, this._attributeName, this.updateView, this);
        this._controller = null;
    }

    updateView()
    {
        this._controller.setValue(this.attributeValue);
    }
}
